import {view, binder, View} from "adajs";
import PowserService from "./state.js";
import User from "./../../../lib/user";

@view({
    className: "powerlist",
    template: "./template.html",
    style: "./style.scss",
    dataset: {
        service: PowserService
    }
})
class PowerList extends View {
    @binder("openNews")
    openNews({item}) {
        if (User.isAdmin()) {
            this.dispatchEvent("gotoPage", `/admin/power/detail?id=${item.id}&columnId=${item.columnId}`);
        } else {
            this.dispatchEvent("gotoPage", `/my/news/detail?id=${item.id}`);
        }
    }
}

export default PowerList;